<?php
//管理员验证类
class ManagerCheck extends Check{
    public function addCheck(&$model,$param) {
        if (self::isNullString($param['user'])) return false;
		if (self::checkStrLength($param['user'], 2, 'min')) return false;
		if (self::checkStrLength($param['user'], 20, 'max')) return false;
        if (self::checkEmail($param['email'])) return false;
        if (self::isNullString($param['passwd'])) return false;
		if (self::checkStrLength($param['passwd'], 6, 'min')) return false;
		if (!self::checkStrEquals($param['passwd'], $param['passwd2'])) return false;
		if (self::isNullString($param['level'])) return false;
        if ($model->isOne(array("user='{$param['user']}'"))) return false;
        return true;
    }
    public function updateCheck(Array $param) {
        if (self::checkEmail($param['email'])) return false;
		if (!self::isNullString($param['passwd']) && self::checkStrLength($param['passwd'], 6, 'min')) return false;
		if (!self::checkStrEquals($param['passwd'], $param['passwd2'])) return false;
		if (self::isNullString($param['level'])) return false;
        return true;
    }
    public function loginCheck(Array $param) {
        if (self::isNullString($param['user'])) return false;
        if (self::isNullString($param['passwd'])) return false;
        if (self::isNullString($param['code']) || !self::checkStrEquals(strtoupper($_SESSION['code']), strtoupper($param['code']))) return false;
        return true;
    }

}